/**
 * Copyright (c) 2011 ~ 2014 Deepin, Inc.
 *               2013 ~ 2014 jouyouyun
 *
 * Author:      jouyouyun <jouyouwen717@gmail.com>
 * Maintainer:  jouyouyun <jouyouwen717@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 **/

package main

import (
	"fmt"
	"time"
)

var (
	termInfo = []int32{0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758}
)

/**
 * 测试二十四节**
 * 某年的第n个节气为几日
 * 31556925974.7为地球公转周期，是毫秒
 * 1890年的正小寒点：01-05 16:02:31，1890年为基准点
 * @param {Number} y 公历年
 * @param {Number} n 第几个节气，从0小寒起算
 * 由于农历24节气交节时刻采用近似算法，可能存在少量误差(30分钟内)
 * 1971 01月06日 07:45:06
 */

func getTermList(year int32) {
	//fmt.Println("year: ", year)
	base := time.Date(1890, 1, 5, 16, 2, 31, 0, time.UTC).Unix()
	//base := time.Date(1971, 1, 6, 7, 45, 6, 0, time.UTC).Unix()
	//fmt.Println("Base Offset: ", base)
	for _, v := range termInfo {
		offset := int64(31556926*(int64(year)-1890) + int64(v)*60)
		//offset := 31536000*(int64(year)-1890) + int64(v)*60
		y, m, d := time.Unix(int64(offset)+base, 0).Date()
		fmt.Printf("Date: %v - %v - %v\n", y, m, d)
	}
}

func main() {
	//t1 := time.Date(2013, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
	//t2 := time.Date(2014, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
	//fmt.Printf("2013: %d, 2014: %d, between: %d\n\n", t1, t2, t2-t1)
	//t3 := time.Date(1890, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
	//t4 := time.Date(1891, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
	//fmt.Printf("1890: %d, 1891: %d, between: %d\n\n", t3, t4, t4-t3)
	//t5 := time.Date(1971, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
	//fmt.Println("1971: ", t5)

	//getTermList(1890)
	getTermList(2014)
}
